# $Id$
class Setup < ActiveRecord::Migration
  def self.up
    create_table :project_report_forms, :force => true do |t|
      t.column :project_id, :int, :default => 0, :null => false
      t.column :name, :string, :default => ''
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
    end

    create_table :project_reports, :force => true do |t|
      t.column :project_report_form_id, :int
      t.column :project_id, :int, :default => 0, :null => false
      t.column :due_date, :date
      t.column :start_date, :date
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
    end

    create_table :project_report_issue_groups, :force => true do |t|
      t.column :project_id, :int, :default => 0, :null => false
      t.column :project_report_form_id, :int
      t.column :query_id, :int, :default => 0, :null => false
    end

    create_table :project_report_teams, :force => true do |t|
      t.column :project_id, :int, :default => 0, :null => false
      t.column :project_report_form_id, :int
      t.column :name, :string, :default => 0, :null => false
    end

    create_table :project_report_teams_users, :force => true, :id => false do |t|
      t.column :project_report_team_id, :int, :default => 0, :null => false
      t.column :user_id, :int, :default => 0, :null => false
    end


  end

  def self.down
    drop_table :project_report_forms
    drop_table :project_reports
    drop_table :project_report_issue_groups
    drop_table :project_report_teams
    drop_table :project_report_teams_users
  end
end
